package cn.edu.hunau.pm.controller;

import cn.edu.hunau.pm.common.ParseBindingResult;
import cn.edu.hunau.pm.common.R;
import cn.edu.hunau.pm.exception.BusinessException;
import cn.edu.hunau.pm.mapper.SearchMapper;
import cn.edu.hunau.pm.pojo.Distinct;
import cn.edu.hunau.pm.pojo.SearchInclusion;
import cn.edu.hunau.pm.pojo.User;
import cn.edu.hunau.pm.request.LoginUser;
import cn.edu.hunau.pm.request.searchs;
import cn.edu.hunau.pm.service.SearchService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

@Controller
public class distinct {
    @Autowired
    private SearchService searchService;
    @PostMapping("/ss")
    @ResponseBody
    public R Search1(@RequestBody @Valid searchs s, BindingResult bindingResult)//BindingResult封装了校验器的结果
    {
        if(bindingResult.hasErrors())
        {
            String message= ParseBindingResult.parse(bindingResult);
            throw new BusinessException(100105,message);
        }


        SearchInclusion si=searchService.sousuo(s.getSousuonr());
        return R.ok().data("searchnr",si);
    }



}